package demo2;

public class Main {

    public static void Print(Shape shape){
        if(shape instanceof Triangle triangle && !triangle.isRightTriangle()){
            triangle.displayInfo();
            return;
        }
        shape.displayInfo();
        System.out.printf("周长：%.2f\n面积：%.2f\n\n",shape.calculatePerimeter(),shape.calculateArea());
    }


    public static void main(String[] args) {
        Circle circle=new Circle("圆形",4);
        Rectangle rectangle=new Rectangle("长方形",3,4);
        Triangle triangle1=new Triangle("三角形？",3,6,15);
        Triangle triangle2=new Triangle("三角形",3,6,8);
        Square square=new Square("正方形",5);

        Shape[] shapes = new Shape[]{circle,rectangle,triangle1,triangle2,square};
        for (Shape shape : shapes){
            Print(shape);
        }

    }
}
